Skip to content

fix(solana): refresh deBridge's placeholder blockhash before signing - #133

Merged
senamakel merged 4 commits into
tinyhumansai:mainfrom
senamakel:solana-swap-blockhash
Nov 13, 2026
Merged

senamakel merged 4 commits into
tinyhumansai:mainfrom
senamakel:solana-swap-blockhash

Conversation

@senamakel

Copy link
Copy Markdown
Member

Every deBridge Solana transaction (same-chain swaps from /v1.0/chain/transaction, and DLN orders from Solana via /v1.0/dln/order/create-tx) was rejected in preflight:

sendTransaction: Transaction simulation failed: Blockhash not found (BlockhashNotFound)

We hit this in production on OpenHuman's linked wallet.

Cause

  • deBridge returns a v0 message whose recentBlockhash is the all-zero placeholder 11111111111111111111111111111111. Its docs tell the integrator to set tx.message.recentBlockhash = (await connection.getLatestBlockhash()).blockhash before signing.
  • sign_and_broadcast_versioned (crypto/chains/solana/versioned.rs) signed the message as received.
  • isBlockhashValid on the zero hash is false at every commitment level. simulateTransaction fails with replaceRecentBlockhash:false and passes with true.

Fix

  • While parsing, the signer records where the blockhash sits, and refuses a blob too short to hold one.
  • When no signature slot is filled yet, it fetches getLatestBlockhash from the same RPC it sends through. It overwrites those 32 bytes in place, so the v0 address lookup tables are never re-encoded, and then signs.
  • A transaction another party has already signed keeps its blockhash, since changing it would invalidate their signature.

Tests

Added in solana/mod_tests.rs:

  • a_debridge_placeholder_blockhash_is_replaced_with_a_fresh_one_before_signing. It checks that the RPC is asked for a blockhash before the send, that the sent message carries it, that it is the only byte range that changed, and that the signature verifies over the sent bytes. Before the fix it failed with left: ["sendTransaction"] right: ["getLatestBlockhash", "sendTransaction"].
  • a_transaction_another_party_already_signed_keeps_its_blockhash.
  • A case for a truncated blockhash.

Two existing tests asserted the bug (that the zero-blockhash message went out untouched). They now check against the broadcast bytes.

Verification

  • scripts/test-features.sh: 1998 passed, 0 failed.
  • cargo fmt --check is clean, and clippy -p tinywallet-web3 --all-targets --all-features -D warnings is clean.

Follow-ups, not in this PR

  • Setting the compute-unit price and limit, which deBridge recommends under congestion.
  • A transaction that uses a durable nonce would have its nonce overwritten. deBridge doesn't send these.

senamakel and others added 4 commits November 13, 2026 15:11
Adds tests for signing v0 transactions with an empty signature slot: a deBridge-style placeholder blockhash is replaced with a fresh one before signing, while a transaction already signed by another party keeps its blockhash so the co-signature stays valid.

Auto-committed-on: cuttlefish
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ransactions

deBridge builds Solana transactions with an all-zero recent blockhash and expects the signer to substitute a fresh one, so unsigned transactions now get the node's latest blockhash before our signature is made. Transactions that already carry another party's signature keep their blockhash, since changing it would void that signature.

Auto-committed-on: cuttlefish
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The versioned transaction tests now check the signature against the bytes actually sent rather than the pre-broadcast wire, and assert that the v0 version prefix is included in the signed message.

Auto-committed-on: cuttlefish
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a malformed versioned transaction case where the account keys are intact but the recent blockhash is cut short, asserting the specific truncation error is returned.

Auto-committed-on: cuttlefish
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@tinysweeper

tinysweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

⚠️ Review of 80fbaa95fd35 stopped because the pull request closed or changed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T15:19:55.150435Z 80fbaa9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant